package com.springbootbase.springbootproject.mapper;

import com.springbootbase.springbootproject.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    //查找用户
    @Select("select * from user where username=#{username} and userType=#{userType}")
    User findByUserName(String username,String userType);

    //用户注册
    @Insert("insert into user(username,password,create_time,update_time,userType)" +
            "values (#{username},#{password},now(),now(),#{userType})")
    void add(String username, String password,String userType);



    @Update("update user set username=#{username},update_time=now() where id=#{id}")
    void updateName(Long id , String username);

    @Update("update studentInfo set phone=#{phone},email=#{email} where id=#{id}")
    void updatePhone(Long id,String phone,String email);

    @Select("select username from user where id=#{id}")
    String getNameById(Long id);

    @Select("select userType from user where id=#{id}")
    String getUserTypeById(Long id);
}
